﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once
#include "GnufExtension.h"
#include "ElementId.h"
namespace gcmp
{
    class IElement;
    class IParameterValueStorage;
}

namespace gnuf
{
    class NameValuePairs;
    class NameValuePairBlock;
    class Block;
    class Item;
}

namespace gnuf
{
    struct ItemInfo
    {
        ItemInfo() : ItemInfo(gcmp::ElementId::InvalidID, false, -1) {}
        ItemInfo(gcmp::ElementId typeId, bool multiValue, Int32 id)
            : TypeId(typeId), MultiValue(multiValue), ParamId(id) {}

        gcmp::ElementId TypeId;
        bool MultiValue;
        Int32 ParamId;
    };

    class GNUF_EXTENSION_EXPORT IParameterDisplayCustom
    {
    public:
        virtual ~IParameterDisplayCustom(){}

        // 自定义参数面板CPropertyItem显示类型。
        virtual gnuf::Item* OnDisplay(
            gnuf::NameValuePairBlock* pNameValuePairBlock, 
            gcmp::IElement* pElement, 
            int parameterId) = 0;
        virtual gnuf::Item* OnDisplay(
            gnuf::NameValuePairBlock* pNameValuePairBlock, 
            const std::vector<gcmp::IElement*> & elements, 
            int parameterId)
        {
            //DBG_WARN(L"This virtual method is not overriden!", L"GMEP", L"2021-05-12");
            return nullptr;
        }

        // 获取当前参数面板所对应的参数值。
        virtual gcmp::OwnerPtr<gcmp::IParameterValueStorage> GetValue() = 0;

        static gnuf::Item* FindItemInCurrentBlock(gnuf::NameValuePairBlock* pBlock, int paramId);
        static gnuf::Item* FindItemInCurrentBlock(gnuf::Block* pBlock, int paramId);
    };
}
